package com.badger.spring.cloud.alibaba.provider;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @EnableDiscoveryClient 开启服务注册和发现
 */
@SpringBootApplication
@EnableDiscoveryClient
public class ProviderApplication {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(ProviderApplication.class, args);
    }

    @RestController
    public class DemoController {

        @Value("${server.port}")
        String port;

        @Value("${spring.cloud.client.ip-address}")
        String address;

        @GetMapping("/demo")
        public String demo() {
            return "我的地址是-->" + address + ":" + port;
        }
    }
}
